unit Class_QBD_GL;

interface
uses
  Classes,SysUtils,Uni,UniEngine;

type
  TQBDGL=class(TUniEngine)
  private
    FJFBKDID    : string;
    FJFBKDFLID  : Integer;
    FJFBKDDWBML : string;
    FJFBKDYBTAG : Integer;
    FZBDFLBH    : Integer;
    FZBDBH      : string;
  protected
    procedure SetParameters;override;
    function  GetStrInsert:string;override;
    function  GetStrUpdate:string;override;
    function  GetStrDelete:string;override;
  public
    function  GetStrsIndex:string;override;
  public
    function  GetNextIdex:Integer;overload;
    function  GetNextIdex(AUniConnection:TUniConnection):Integer;overload;
  public
    function  CheckExist(AUniConnection:TUniConnection):Boolean;override;
  public
    destructor  Destroy; override;
    constructor Create;  
  published
    property JFBKDID    : string read FJFBKDID     write FJFBKDID;
    property JFBKDFLID  : Integer read FJFBKDFLID   write FJFBKDFLID;
    property JFBKDDWBML : string read FJFBKDDWBML  write FJFBKDDWBML;
    property JFBKDYBTAG : Integer read FJFBKDYBTAG  write FJFBKDYBTAG;
    property ZBDFLBH    : Integer read FZBDFLBH     write FZBDFLBH;
    property ZBDBH      : string read FZBDBH       write FZBDBH;    
  public
    class function  ReadDS(AUniQuery:TUniQuery):TUniEngine;override;
    class procedure ReadDS(AUniQuery:TUniQuery;var Result:TUniEngine);override;
    class function  CopyIt(AJFBKDGL:TQBDGL):TQBDGL;overload;        
    class procedure CopyIt(AJFBKDGL:TQBDGL;var Result:TQBDGL);overload;       
  end;

implementation

{ TQBDGL }
procedure TQBDGL.SetParameters;
begin
  inherited;
  with FUniSQL.Params do
  begin
    case FOptTyp of
      otAddx:
      begin
        ParamByName('JFBKD_ID').Value := JFBKDID;
        ParamByName('JFBKD_FL_ID').Value := JFBKDFLID;
        ParamByName('JFBKD_DWBML').Value := JFBKDDWBML;
        ParamByName('JFBKD_YBTAG').Value := JFBKDYBTAG;
        ParamByName('ZBD_FL_BH').Value := ZBDFLBH;
        ParamByName('ZBD_BH').Value := ZBDBH; 
      end;
      otEdit:
      begin
        ParamByName('JFBKD_ID').Value := JFBKDID;
        ParamByName('JFBKD_FL_ID').Value := JFBKDFLID;
        ParamByName('JFBKD_DWBML').Value := JFBKDDWBML;
        ParamByName('JFBKD_YBTAG').Value := JFBKDYBTAG;
        ParamByName('ZBD_FL_BH').Value := ZBDFLBH;
        ParamByName('ZBD_BH').Value := ZBDBH; 
      end;  
      otDelt:
      begin
        ParamByName('JFBKD_ID').Value    := JFBKDID;
        ParamByName('JFBKD_FL_ID').Value := JFBKDFLID;
        ParamByName('JFBKD_DWBML').Value := JFBKDDWBML;
        ParamByName('JFBKD_YBTAG').Value := JFBKDYBTAG;  
      end;  
    end;
  end;
end;

function TQBDGL.CheckExist(AUniConnection: TUniConnection): Boolean;
begin
  Result:=CheckExist('TBL_JFBKD_GL',['JFBKD_ID',JFBKDID,'JFBKD_FL_ID',JFBKDFLID,'JFBKD_DWBML',JFBKDDWBML,'JFBKD_YBTAG',JFBKDYBTAG],AUniConnection);
end;

function TQBDGL.GetNextIdex: Integer;
begin

end;

function TQBDGL.GetNextIdex(AUniConnection: TUniConnection): Integer;
begin

end;

function TQBDGL.GetStrDelete: string;
begin
  Result:='DELETE FROM TBL_JFBKD_GL WHERE   JFBKD_ID=:JFBKD_ID AND JFBKD_FL_ID=:JFBKD_FL_ID AND JFBKD_DWBML=:JFBKD_DWBML AND JFBKD_YBTAG=:JFBKD_YBTAG AND ZBD_FL_BH=:ZBD_FL_BH AND ZBD_BH=:ZBD_BH';
end;

function TQBDGL.GetStrInsert: string;
begin
  Result:='INSERT INTO TBL_JFBKD_GL'
         +'    ( JFBKD_ID, JFBKD_FL_ID, JFBKD_DWBML, JFBKD_YBTAG, ZBD_FL_BH'
         +'    , ZBD_BH)'
         +'    VALUES'
         +'    (:JFBKD_ID,:JFBKD_FL_ID,:JFBKD_DWBML,:JFBKD_YBTAG,:ZBD_FL_BH'
         +'    ,:ZBD_BH)';
end;

function TQBDGL.GetStrsIndex: string;
begin
  Result:=Format('%S-%D-%S-%D',[JFBKDID,JFBKDFLID,JFBKDDWBML,JFBKDYBTAG]);
end;

function TQBDGL.GetStrUpdate: string;
begin
  Result:='UPDATE  TBL_JFBKD_GL SET'
         +'    ZBD_FL_BH=:ZBD_FL_BH,'
         +'    ZBD_BH=:ZBD_BH'
         +'    WHERE JFBKD_ID=:JFBKD_ID'
         +'    AND   JFBKD_FL_ID=:JFBKD_FL_ID'
         +'    AND   JFBKD_DWBML=:JFBKD_DWBML'
         +'    AND   JFBKD_YBTAG=:JFBKD_YBTAG'; 
end;

constructor TQBDGL.Create;
begin

end;

destructor TQBDGL.Destroy;
begin

  inherited;
end;

class function TQBDGL.ReadDS(AUniQuery: TUniQuery): TUniEngine;
begin
  Result:=TQBDGL.Create;
  with TQBDGL(Result) do
  begin
    JFBKDID    :=AUniQuery.FieldByName('JFBKD_ID').AsString;
    JFBKDFLID  :=AUniQuery.FieldByName('JFBKD_FL_ID').AsInteger;
    JFBKDDWBML :=AUniQuery.FieldByName('JFBKD_DWBML').AsString;
    JFBKDYBTAG :=AUniQuery.FieldByName('JFBKD_YBTAG').AsInteger;
    ZBDFLBH    :=AUniQuery.FieldByName('ZBD_FL_BH').AsInteger;
    ZBDBH      :=AUniQuery.FieldByName('ZBD_BH').AsString;
  end;  
end;

class procedure TQBDGL.ReadDS(AUniQuery: TUniQuery; var Result: TUniEngine);
begin
  if Result=nil then Exit;
  with TQBDGL(Result) do
  begin
    JFBKDID    :=AUniQuery.FieldByName('JFBKD_ID').AsString;
    JFBKDFLID  :=AUniQuery.FieldByName('JFBKD_FL_ID').AsInteger;
    JFBKDDWBML :=AUniQuery.FieldByName('JFBKD_DWBML').AsString;
    JFBKDYBTAG :=AUniQuery.FieldByName('JFBKD_YBTAG').AsInteger;
    ZBDFLBH    :=AUniQuery.FieldByName('ZBD_FL_BH').AsInteger;
    ZBDBH      :=AUniQuery.FieldByName('ZBD_BH').AsString;
  end;  
end;

class function  TQBDGL.CopyIt(AJFBKDGL: TQBDGL): TQBDGL;
begin
  Result:=TQBDGL.Create;
  TQBDGL.CopyIt(AJFBKDGL,Result)
end;

class procedure TQBDGL.CopyIt(AJFBKDGL:TQBDGL;var Result:TQBDGL);
begin
  if Result=nil then Exit;
  Result.JFBKDID    :=AJFBKDGL.JFBKDID;
  Result.JFBKDFLID  :=AJFBKDGL.JFBKDFLID;
  Result.JFBKDDWBML :=AJFBKDGL.JFBKDDWBML;
  Result.JFBKDYBTAG :=AJFBKDGL.JFBKDYBTAG;
  Result.ZBDFLBH    :=AJFBKDGL.ZBDFLBH;
  Result.ZBDBH      :=AJFBKDGL.ZBDBH;
end;

end.

